/*
 * Copyright (C) 2015-2016  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


#include "PlanetWars2dRT-core/specific/model/planet_default.h"


EXTERN_C_BEGIN


void
planet_set_default_size(struct planet_t* p)
{
  p->size.x = PLANET_SIZE_X_DEFAULT;
  p->size.y = PLANET_SIZE_X_DEFAULT;
}

void
planet_set_default_life(struct planet_t* p)
{
  p->life_current = PLANET_LIFE_MAX_DEFAULT;
  p->life_max     = PLANET_LIFE_MAX_DEFAULT;
}

void
planet_set_default_level_current_no_check(struct planet_t* p)
{
  p->level_current = PLANET_LEVEL_CURRENT_DEFAULT;
}

bool
planet_set_default_level_current(struct planet_t* p)
{
  if(p->level_max < PLANET_LEVEL_CURRENT_DEFAULT)
    {
      return false;
    }
  
  planet_set_default_level_current_no_check(p);
  return true;
}

void
planet_set_default_level_max_no_check(struct planet_t* p)
{
  p->level_max = PLANET_LEVEL_MAX_DEFAULT;
}

bool
planet_set_default_level_max(struct planet_t* p)
{
  if(p->level_current > PLANET_LEVEL_MAX_DEFAULT)
    {
      return false;
    }
  
  planet_set_default_level_max_no_check(p);
  return true;
}

void
planet_set_default_level_changer_no_check(struct planet_t* p)
{
  p->level_changer = PLANET_LEVEL_CHANGER_DEFAULT;
}

void
planet_set_default_level(struct planet_t* p)
{
  planet_set_default_level_current_no_check(p);
  planet_set_default_level_max_no_check    (p);
  planet_set_default_level_changer_no_check(p);
}

void
planet_set_default(struct planet_t* p)
{
  planet_set_default_size (p);
  planet_set_default_life (p);
  planet_set_default_level(p);
  p->producing_capacity    = PLANET_PRODUCING_CAPACITY_DEFAULT;
  p->nb_updates_to_produce = PLANET_NB_UPDATES_TO_PRODUCE_DEFAULT;
  p->produce_when_neutral  = PLANET_PRODUCE_WHEN_NEUTRAL_DEFAULT;
}


EXTERN_C_END
